﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using JihankiLib;

namespace GuiJihanki
{
    partial class MoneyBoxControl : UserControl
    {
        private MoneyBoxMachine ctrl;

        public MoneyBoxControl()
        {
            InitializeComponent();
        }

        public void Initialize(MoneyBoxMachine ctrl)
        {
            this.ctrl = ctrl;
            this.ctrl.AddedMoney += new EventHandler<AddedMoneyEventArgs>(ctrl_AddedMoney);
            this.ctrl.RejectedAllMoney += new EventHandler<RejectedAllMoneyEventArgs>(ctrl_RejectedAllMoney);
        }

        void ctrl_RejectedAllMoney(object sender, JihankiLib.RejectedAllMoneyEventArgs e)
        {
            lblTotal.Text = "0";
        }

        void ctrl_AddedMoney(object sender, JihankiLib.AddedMoneyEventArgs e)
        {
            lblTotal.Text = e.Total.Value.ToString();
        }

        private void btn1000_Click(object sender, EventArgs e)
        {
            ctrl.AddMoney(1000);
        }

        private void btn500_Click(object sender, EventArgs e)
        {
            ctrl.AddMoney(500);
        }

        private void btn100_Click(object sender, EventArgs e)
        {
            ctrl.AddMoney(100);
        }

        private void btn50_Click(object sender, EventArgs e)
        {
            ctrl.AddMoney(50);
        }

        private void btn10_Click(object sender, EventArgs e)
        {
            ctrl.AddMoney(10);
        }

        private void btnReject_Click(object sender, EventArgs e)
        {
            ctrl.RejectAllMoney();
        }
    }
}
